package com.king.platform.utils;

import jakarta.servlet.http.HttpServletResponse;
import lombok.experimental.UtilityClass;

import java.io.IOException;
import java.io.OutputStream;

@UtilityClass
public class HttpResponseUtil {

  public static OutputStream excelOutput(HttpServletResponse response, String fileName) throws IOException {
    response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    response.setCharacterEncoding("utf-8");
    response.setHeader("Content-disposition", "attachment;filename*=utf-8''${fileNameEncode + '_' + datetime}.xlsx");
    return response.getOutputStream();
  }


}
